import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author
 * @version 1.0.0
 * @description
 * @createTime 2024/08/14
 */
public class GetPrinter {

    public static void main(String[] args) {
        PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null, null);
        System.out.println(Arrays.stream(printServices).map(PrintService::getName).collect(Collectors.toList()));
        Arrays.stream(printServices).forEach(item -> {
            System.out.println(item.getName());
        });

        Map<String, Object> result = new HashMap<>();
        result.put("data", Arrays.stream(printServices).map(PrintService::getName).collect(Collectors.toList()));
        System.out.println(result);

    }
}
